package org.pearl.thread.demo.test001;

import org.pearl.thread.demo.cache.annotation.Cacheable;

import java.beans.Expression;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by TD on 2021/4/13
 * 截取身份证测试
 */
public class CardTest extends Object {

    @Cacheable(key = "")
    public static void main(String[] args) {
        String content = "皖F26581 00-01-6C-06-A6-29 皖F26584   00:01:6C:06:A6:29 33062119911209004x  浙F601ML_0 8428cc88-2e76-4188-8495-1c26858c6c8f  13622222222 chlorine-finder@testchlorine.com 1.1.1.1 124.234.223.12 CDCD:910A:2222:5498:8475:1111:3900:2020 111111111111111 111111111111111234";
        String regex = "([1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx])|([1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3})";

        Map dataMap = new HashMap<>();
        dataMap.put("ssss", content);
        for (Object key : dataMap.keySet()) {
            String value = dataMap.get(key).toString();//
            System.out.println("key:" + key + " vlaue:" + value);
        }
        // 截取身份证
        String card = "";
        Pattern p = Pattern.compile(regex);
        for (Object obj : dataMap.values()) {
            String value = obj.toString();//
            System.err.println(value);
            Matcher matcher = p.matcher(value);
            boolean b = matcher.find();
            System.err.println(b);
            if (b) {
                System.err.println(matcher.group(1));
            }
        }

    }
}
